unit cef_tools;

{$mode objfpc}{$H+}

interface

uses
    Classes, SysUtils, cef3api, cef3types;

function GetCEFVersion: string;
function GetChromiumVersion: string;

function GetCEFErrorText(const AErrorCode: TCefErrorCode): string;

implementation

function GetCEFVersion: string;
begin
    Result := Format('%d.%d.%d', [cef_version_info(0), cef_version_info(4), cef_version_info(1)]);
end;

function GetChromiumVersion: string;
begin
    Result := Format('%d.%d.%d.%d', [cef_version_info(2), cef_version_info(3), cef_version_info(4),
        cef_version_info(5)]);
end;

function GetCEFErrorText(const AErrorCode: TCefErrorCode): string;
begin
    case AErrorCode of
        ERR_NONE:
            Result := 'None';
        ERR_FAILED:
            Result := 'Failed';
        ERR_ABORTED:
            Result := 'Aborted';
        ERR_INVALID_ARGUMENT:
            Result := 'Invalid argument';
        ERR_INVALID_HANDLE:
            Result := 'Invalid handle';
        ERR_FILE_NOT_FOUND:
            Result := 'File not found';
        ERR_TIMED_OUT:
            Result := 'Timed out';
        ERR_FILE_TOO_BIG:
            Result := 'File too big';
        ERR_UNEXPECTED:
            Result := 'Unexpected';
        ERR_ACCESS_DENIED:
            Result := 'Access denied';
        ERR_NOT_IMPLEMENTED:
            Result := 'Not implemented';
        ERR_INSUFFICIENT_RESOURCES:
            Result := 'Insufficient resources';
        ERR_OUT_OF_MEMORY:
            Result := 'Out of memory';
        ERR_UPLOAD_FILE_CHANGED:
            Result := 'Upload file changed';
        ERR_SOCKET_NOT_CONNECTED:
            Result := 'Socket not connected';
        ERR_FILE_EXISTS:
            Result := 'File exists';
        ERR_FILE_PATH_TOO_LONG:
            Result := 'File path too long';
        ERR_FILE_NO_SPACE:
            Result := 'File no space';
        ERR_FILE_VIRUS_INFECTED:
            Result := 'File virus infected';
        ERR_BLOCKED_BY_CLIENT:
            Result := 'Blocked by client';
        ERR_NETWORK_CHANGED:
            Result := 'Network changed';
        ERR_BLOCKED_BY_ADMINISTRATOR:
            Result := 'Blocked by administrator';
        ERR_SOCKET_IS_CONNECTED:
            Result := 'Socket is connected';
        ERR_BLOCKED_ENROLLMENT_CHECK_PENDING:
            Result := 'Blocked enrollment check pending';
        ERR_CONNECTION_CLOSED:
            Result := 'Connection closed';
        ERR_CONNECTION_RESET:
            Result := 'Connection reset';
        ERR_CONNECTION_REFUSED:
            Result := 'Connection refused';
        ERR_CONNECTION_ABORTED:
            Result := 'Connection aborted';
        ERR_CONNECTION_FAILED:
            Result := 'Connection failed';
        ERR_NAME_NOT_RESOLVED:
            Result := 'Name not resolved';
        ERR_INTERNET_DISCONNECTED:
            Result := 'Internet disconnected';
        ERR_SSL_PROTOCOL_ERROR:
            Result := 'SSL protocol error';
        ERR_ADDRESS_INVALID:
            Result := 'Address invalid';
        ERR_ADDRESS_UNREACHABLE:
            Result := 'Address unreachable';
        ERR_SSL_CLIENT_AUTH_CERT_NEEDED:
            Result := 'SSL client authentication certificate needed';
        ERR_TUNNEL_CONNECTION_FAILED:
            Result := 'Tunnel connection failed';
        ERR_NO_SSL_VERSIONS_ENABLED:
            Result := 'No SSL versions enabled';
        ERR_SSL_VERSION_OR_CIPHER_MISMATCH:
            Result := 'SSL version or cipher mismatch';
        ERR_SSL_RENEGOTIATION_REQUESTED:
            Result := 'SSL renegotiation requested';
        ERR_CONNECTION_TIMED_OUT:
            Result := 'Connection timed out';
        ERR_CERT_COMMON_NAME_INVALID:
            Result := 'Certificate common name invalid';
        ERR_CERT_DATE_INVALID:
            Result := 'Certificate date invalid';
        ERR_CERT_AUTHORITY_INVALID:
            Result := 'Certificate authority invalid';
        ERR_CERT_CONTAINS_ERRORS:
            Result := 'Certificate contains errors';
        ERR_CERT_NO_REVOCATION_MECHANISM:
            Result := '';
        ERR_CERT_UNABLE_TO_CHECK_REVOCATION:
            Result := '';
        ERR_CERT_REVOKED:
            Result := '';
        ERR_CERT_INVALID:
            Result := '';
        ERR_CERT_END:
            Result := '';
        ERR_INVALID_URL:
            Result := 'Invalid URL';
        ERR_DISALLOWED_URL_SCHEME:
            Result := '';
        ERR_UNKNOWN_URL_SCHEME:
            Result := '';
        ERR_TOO_MANY_REDIRECTS:
            Result := '';
        ERR_UNSAFE_REDIRECT:
            Result := '';
        ERR_UNSAFE_PORT:
            Result := '';
        ERR_INVALID_RESPONSE:
            Result := '';
        ERR_INVALID_CHUNKED_ENCODING:
            Result := '';
        ERR_METHOD_NOT_SUPPORTED:
            Result := '';
        ERR_UNEXPECTED_PROXY_AUTH:
            Result := '';
        ERR_EMPTY_RESPONSE:
            Result := '';
        ERR_RESPONSE_HEADERS_TOO_BIG:
            Result := '';
        ERR_CACHE_MISS:
            Result := '';
        ERR_INSECURE_RESPONSE:
            Result := '';
        else
            Result := 'Error description not specified';
    end;
end;

end.



